package org.example.thymeleaf.demo.demos.message;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @author wzx
 * @date 2024/9/20 15:13
 * @description: 返回结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Accessors
public class Result<T> {
    private String code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data) {
        return Result.<T>builder().code("200").msg("success").data(data).build();
    }

    public static <T> Result<T> fail(String msg) {
        return Result.<T>builder().code("500").msg(msg).build();
    }
}
